﻿
Imports osi.root.connector

Public Class comparable_type
    Inherits pointer(Of Type)
    Implements IComparable(Of comparable_type)

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal i As Type)
        MyBase.New(i)
    End Sub

    Public Sub New(ByVal i As _pointer(Of Type))
        MyBase.New(i)
    End Sub

    Public Shared Function compare_type(ByVal i As Type, ByVal j As Type) As Int32
        Dim cmp As Int32 = 0
        cmp = object_compare(i, j)
        If cmp = object_compare_undetermined Then
            Return connector.compare(i.GUID(), j.GUID())
        Else
            Return cmp
        End If
    End Function

    Protected Overrides Function compare(ByVal i As Type, ByVal j As Type) As Int32
        Return compare_type(i, j)
    End Function

    Public Overloads Function CompareTo(ByVal other As comparable_type) As Int32 _
                                       Implements IComparable(Of comparable_type).CompareTo
        Return MyBase.CompareTo(other)
    End Function
End Class
